<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>权限列表</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../css/oksub.css">
    <script type="text/javascript" src="../../lib/loading/okLoading.js"></script>
</head>
<body class="ok-body-scroll">
<div class="ok-body">

    <div class="layui-row">
        <div class="layui-col-md3">
            <div id="fileTree"></div>
        </div>
        <div class="layui-col-md9">
            <form class="layui-form layui-form-pane ok-form">

                <div class="layui-form-item layui-form-text">
                    <div class="layui-input-block">
                        <textarea name="content" id="content"  class="layui-textarea" style="height:500px" ></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="addArticle">保存</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<!--js逻辑-->
<script src="../../lib/layui/layui.js"></script>
<script>
    var rowData;
    layui.use(["element", "table", "laydate", "tree", "okUtils", "okMock",'okLayer','jquery'], function () {
        let table = layui.table;
        let laydate = layui.laydate;
        let tree = layui.tree;
        let okUtils = layui.okUtils;
        let okMock = layui.okMock;
        let okLayer=layui.okLayer;
        let $=layui.jquery;
        okLoading.close();
        laydate.render({elem: '#startTime', type: "datetime"});
        laydate.render({elem: '#endTime', type: "datetime"});



        okUtils.ajax("/sysFile/list", "get", null, true).done(function (response) {
            tree.render({
                elem: '#fileTree',
                data: response.data,
                showCheckbox: true,
                id: 'id',
                isJump: false,
                click: function (obj) {
                    var data = obj.data;
               //     layer.msg('状态：' + obj.state + '<br>节点数据：' + JSON.stringify(data));
                    getContent(data.path);
                }
            });


        }).fail(function (error) {
            console.log(error)
        });

        function getContent(filePath){
            if(filePath==null){
                layer.msg('请选择文件');
                return ;
            }
            okUtils.ajax("/sysFile/getContent", "post", {filePath:filePath}, true).done(function (response) {
                $('#content').val(response.data);
            }).fail(function (error) {
                console.log(error)
            });
        }


    });
</script>
<!-- 头工具栏模板 -->
<script type="text/html" id="toolbarTpl">
    <div class="layui-btn-container">
        <div class="layui-inline" lay-event="add"><i class="layui-icon layui-icon-add-1"></i></div>
        <div class="layui-inline" lay-event="batchDel"><i class="layui-icon layui-icon-delete"></i></div>
    </div>
</script>
<!--行工具栏模板-->
<script type="text/html" id="operationTpl">
    <a href="javascript:" title="编辑" lay-event="edit"><i class="layui-icon">&#xe642;</i></a>
    <a href="javascript:" title="删除" lay-event="del"><i class="layui-icon">&#xe640;</i></a>
</script>

<script type="text/html" id="typeTpl">
    {{#  if(d.type == 0){ }}
    <span class="layui-btn layui-btn-normal layui-btn-xs">菜单</span>
    {{#  } else if(d.type == 1){ }}
    <span class="layui-btn layui-btn-warm layui-btn-xs">功能</span>

    {{#  } }}
</script>
<script type="text/html" id="statusTpl">
    {{#  if(d.status == 0){ }}
    <span class="layui-btn layui-btn-normal layui-btn-xs">启用</span>
    {{#  } else if(d.status == 1) { }}
    <span class="layui-btn layui-btn-warm layui-btn-xs">停用</span>
    {{#  } else if(d.status == 2) { }}
    <span class="layui-btn layui-btn-danger layui-btn-xs">删除</span>
    {{#  } }}
</script>
</body>
</html>
